#include <iostream>
#include <Windows.h>
#include <conio.h>
using namespace std;

DWORD WINAPI Thread1(LPVOID param){
	cout << "Press any key :)...........\n";
	_getch();
	return 0;
}

void main(){
	HANDLE hThread = NULL;
	HANDLE hThread1 = CreateThread(NULL, 0, Thread1, NULL, NULL, NULL);
	HANDLE hThread2 = CreateThread(NULL, 0, Thread1, NULL, NULL, NULL);
	
	//DWORD result = WaitForSingleObject(hThread1, 2000/*INFINITE - forever*/);
	HANDLE arr[2] = {hThread1, hThread2};
	/*
	......
	*/
	
	DWORD result = WaitForMultipleObjects(2, arr, TRUE, 3000/*INFINITE - forever*/);

	switch(result){
	case WAIT_OBJECT_0:
		cout << "WAIT_OBJECT_0\n";
		break;
	case WAIT_TIMEOUT:
		cout << "WAIT_TIMEOUT\n";
		break;
	case WAIT_FAILED:
		cout << "WAIT_FAILED\n";
		//cout << GetLastError() << endl;

		break;
	case WAIT_ABANDONED:
		cout << "WAIT_ABANDONED\n";
		break;			
	}

	cout << "Main ...........\n";
}